package oneD.t3dviewer2;

/* tuple3d.java

   History:

   12 Jul 2006  Created.
 */

/**
 * A class for storing an ordered triplet of float values. Roughly based on
 * javax.vecmath.Tuple3d except it includes dot() which is only introduced in
 * javax.vecmath.Vector3d.
 */
public class tuple3d {
	protected float m_x, m_y, m_z;

	/** Create a new tuple3d. */
	public tuple3d(float x, float y, float z) {
		set(x, y, z);
	}

	/** Set the tuple3d values from floats. */
	public void set(float x, float y, float z) {
		m_x = x;
		m_y = y;
		m_z = z;
	}

	/** Set the tuple3d values from another tuple3d. */
	public void set(tuple3d tuple) {
		m_x = tuple.m_x;
		m_y = tuple.m_y;
		m_z = tuple.m_z;
	}

	/** Scale the tuple3d values by the specified value. */
	public void scale(float f) {
		m_x *= f;
		m_y *= f;
		m_z *= f;
	}

	/** Compute dot product of the tuple3d with another tuple3d. */
	public float dot(tuple3d tuple) {
		return m_x * tuple.m_x + m_y * tuple.m_y + m_z * tuple.m_z;
	}

	/** Access x value of the tuple3d. */
	public float x() {
		return m_x;
	}

	/** Access y value of the tuple3d. */
	public float y() {
		return m_y;
	}

	/** Access z value of the tuple3d. */
	public float z() {
		return m_z;
	}

	/** Generate a String representation of this tuple3d. */
	public String toString() {
		return ("[" + m_x + "," + m_y + "," + m_z + "]");
	}
}
